﻿using Collection.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using static System.Console;

namespace 集合
{
    internal class Program
    {
        static void Main(string[] args)
        {
            WriteLine("Create an Array type collection of Animal objects and use it:");
            Animal[] animals = new Animal[2];
            Cow myCow1 = new Cow("Lea");
            animals[0] = myCow1;

            animals[1] = new Chicken("Noa");

            foreach (var animal in animals)
            {
                WriteLine($"New {animal.ToString()} object added to Array" +
                    $"collection ,Name = {animal.Name}");
            }
            WriteLine($"Array collection contains {animals.Length} objects");
            animals[0].Feed();

            ((Chicken)animals[1]).LayEgg();
            WriteLine();

            WriteLine("Create an ArrayList type collection of Animal objects and use it");
            ArrayList arrayList = new ArrayList();
            Cow myCow2 = new Cow("Donna");
            arrayList.Add(myCow2);
            arrayList.Add(new Chicken("Andrea"));
            foreach (var animal in animals)
            {
                WriteLine($"New {animal.ToString()} object added to Array" +
                    $"collection ,Name = {animal.Name}");
            }
            ((Cow)arrayList[0]).Feed();
            ((Chicken)arrayList[1]).LayEgg();
            WriteLine();



            ReadKey();
        }
    }

    
}
